<template>
	<view>
		<navigator url="/pages/store/couponCreation">
		  <view class="cartBtn">
		  	创建优惠券
		  </view>
		</navigator>
		<scroll-view
		        class="goods-scroll-content"
		        scroll-y
		        @scrolltolower="loadData"
		        refresher-triggered="triggerData"
		>
		<view class="itemC" v-for="item,index of list" :key="index">
			<view class="" style="margin: 10rpx 0;display: flex;align-items: flex-end;">
				<view class="">
					活动名称：
				</view>
				<view class="titleText">
					{{item.promotionName}}
				</view>
			</view>
			<view class="">
				<view class="" style="margin-bottom: 10rpx;">
					<span>优惠券名称：</span><span style="font-size: 32rpx;">{{item.couponName}}</span>
				</view>
				<view class="" style="font-size: 22rpx;color: #999;">
				   	<span>活动时间：</span><span>{{item.startTime}} ~ {{item.endTime}}</span>
				</view>
			</view>
			<view class="">
				<view class="">
					活动描述：
				</view>
				<view class="">
					{{item.description}}
				</view>
			</view>
			<view class="upBtn">
				<view class="btnView" @click="upDataItem(item.id)">
					修改优惠券
				</view>
			</view>
		</view>
		</scroll-view>
	</view>
</template>

<script>
		import {selectStoreCouponList} from "@/api/store"
    import storage from "@/utils/storage";
	export default {
		data() {
			return {
				queryParams: {
				    pageSize: 10,
				    pageNumber: 1,
				},
				list:[]
			}
		},
		onLoad(){
			// this.getSelectStoreCouponList()
		},
		onShow(){
			this.queryParams.pageNumber = 1
			this.list = []
			this.getSelectStoreCouponList()
		},
		methods: {
			getSelectStoreCouponList(){
        this.queryParams.storeId=storage.getUserInfo().storeId
				selectStoreCouponList(this.queryParams).then(res => {

				    if (res.data.success) {

              if(res.data.result.records.length>0){
                this.list = this.list.concat(res.data.result.records);
              }

				    }
				})
			},
			// 加载数据
			loadData() {
			        this.queryParams.pageNumber++;
			        setTimeout(() => {
			            this.getSelectStoreCouponList();
			        }, 800)
			},
			upDataItem(id){
				uni.navigateTo({
					url: '/pages/store/couponCreation?id='+ id + '&type=updata'
				});
			},
		}
	}
</script>

<style>
	.itemC{
		width: 95%;
		background: #FFF;
		margin: 5px auto;
		border-radius: 5px;
		padding: 10px;
		position: relative;
	}
	.titleText{
		font-size: 18px;
		color: red;
		font-weight: bold;
	}
	.cartBtn{
		    width: 30vw;
		    height: 10vw;
		    background: red;
		    border-radius: 5px;
		    display: flex;
		    justify-content: center;
		    align-items: center;
		    color: #FFF;
		    position: relative;
		    left: 65vw;
		    margin: 3vw 1vw;
	}
	.goods-scroll-content {
	    height: 85vh;
	}
	.upBtn{
		position: absolute;
		top: 20rpx;
		right: 10rpx;
	}
	.btnView{
		background: red;
		padding: 1vw;
		color: #FFF;
		border-radius: 5px;
	}
</style>
